Skip to content

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Jul 24, 2025

Remove the VersionedField in favor of an optional versions field on a patch.

--

There are 2 ways to patch the code in aws/cloudflare:

  • the CodePatcher is used to patch the files before the build
  • the ContentUpdater is used to patch the files within an ESBuild build

They are similar but do not have feature parity.

The Cf adapter mostly uses the ContentUpdater but does not really use the version range for now.
With the recent release of 15.4, the need to apply different patches according to the Next version is becoming more important.

What I'd like to do with this PR (and some follow up PRs) is to unify the 2 mechanisms.

Next steps:

  • The version range is pretty limited, I'd like to introduce a predicate in addition to the current string to allow for more flexibiliy, i.e. using the semver package - For example, we do not currently support ">", "<", "15" but only ">=", "<=", "15.0.0"
  • Try to unify and share as much code as possible, keeping the 2 ways to apply the patches. Either before or during ESBuild.

@vicb vicb requested a review from conico974 July 24, 2025 20:27
Copy link

changeset-bot bot commented Jul 24, 2025

🦋 Changeset detected

Latest commit: 92cb060

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@opennextjs/aws Patch
app-pages-router Patch
app-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 26.55% 2591 / 9756
🔵 Statements 26.55% 2591 / 9756
🔵 Functions 54.26% 140 / 258
🔵 Branches 73.15% 616 / 842
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/open-next/src/build/patch/codePatcher.ts 50% 95.45% 66.66% 50% 65-66, 122-177
packages/open-next/src/build/patch/patches/patchBackgroundRevalidation.ts 100% 100% 100% 100%
packages/open-next/src/build/patch/patches/patchEnvVar.ts 100% 100% 100% 100%
packages/open-next/src/build/patch/patches/patchFetchCacheISR.ts 100% 100% 100% 100%
packages/open-next/src/build/patch/patches/patchFetchCacheWaitUntil.ts 100% 100% 100% 100%
packages/open-next/src/build/patch/patches/patchNextServer.ts 100% 100% 100% 100%
packages/open-next/src/plugins/content-updater.ts 0% 0% 0% 0% 1-107
Generated in workflow #1366 for commit 92cb060 by the Vitest Coverage Report Action

Copy link

pkg-pr-new bot commented Jul 24, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/aws@931

commit: 92cb060

Copy link
Contributor

@conico974 conico974 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great. Thanks!!!

@vicb vicb merged commit c48ac95 into main Jul 25, 2025
3 checks passed
@vicb vicb deleted the vicb/patch-1 branch July 25, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants